package Day10test;

public class SupperArray {
    private Object [] objects = new Object[0];
    /**
     * 获取数组长度
     * */
    public int size(){
        return objects.length;
    }
    /**
     *根据下标获取数组元素
     * */
    public Object get(int index){
        return objects[index];
    }
    /**
     *添加数据
     * */
    public void add(Object value){

        Object [] newObject = new Object[objects.length + 1];

        for (int i = 0 ; i < objects.length; i++){
            newObject[i] = objects[i];
        }
        newObject[newObject.length - 1] = value;

        objects = newObject;

    }
    /**
     *   根据下标删除
     * */
    public void remove(int index){

        Object[] newObject = new Object[objects.length - 1];
        for (int i = 0; i < newObject.length; i++) {
            newObject[i] = objects[i];
            if (i >= index) {
                newObject[i] = objects[i + 1];
            }
        }
        objects = newObject;


    }
}
